<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

/**
 * App\GameConfig
 *
 * @property int $id
 * @property int|null $game_id
 * @property int|null $prize_id
 * @property int|null $level
 * @property int|null $chance
 * @property \Carbon\Carbon|null $created_at
 * @property \Carbon\Carbon|null $updated_at
 * @property string|null $color 颜色排序
 * @property string|null $name
 * @property-read \App\Game|null $game
 * @property-read \App\GamePrize|null $gamePrize
 * @method static \Illuminate\Database\Eloquent\Builder|\App\GameConfig whereChance($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\GameConfig whereColor($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\GameConfig whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\GameConfig whereGameId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\GameConfig whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\GameConfig whereLevel($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\GameConfig whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\GameConfig wherePrizeId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\GameConfig whereUpdatedAt($value)
 * @mixin \Eloquent
 */
class GameConfig extends Model
{
    protected $table="game_configs";
    //
    public function getColorAttribute($value){
        return json_decode($value,true);
    }
    public function setColorAttribute($value){
        $this->attributes['color']=json_encode($value);
    }
    public function game(){
        return $this->belongsTo('App\Game','game_id');
    }
    public function gamePrize(){
        return $this->belongsTo('App\GamePrize','prize_id');
    }
}
